//
//  USPhotoUploadTool.m
//  us
//
//  Created by karry on 2025/4/15.
//

#import "USPhotoUploadTool.h"

@implementation USPhotoUploadTool

+ (NSString *)mediaCacheDirectory {
    NSString *cachePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"USMediaCache"];
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (![[NSFileManager defaultManager] fileExistsAtPath:cachePath]) {
            NSError *error = nil;
            [[NSFileManager defaultManager] createDirectoryAtPath:cachePath withIntermediateDirectories:YES attributes:nil error:&error];
            if (error) {
                NSLog(@"创建缓存目录失败: %@", error);
            }
        }
    });
    
    return cachePath;
}

+ (NSString *)imagePathWithUUID:(NSString *)uuid {
    NSString *fileName = [NSString stringWithFormat:@"img_%@.jpg", uuid];
    return [[self mediaCacheDirectory] stringByAppendingPathComponent:fileName];
}

+ (NSString *)videoPathWithUUID:(NSString *)uuid {
    NSString *fileName = [NSString stringWithFormat:@"vid_%@.mp4", uuid];
    return [[self mediaCacheDirectory] stringByAppendingPathComponent:fileName];
}


@end
